﻿@using KMF.Common
@using KMF.Utility
@using KMF.WebUI.CustomHelpers
@{
    var cateListAll = (List<ProductCategoryDto>)ViewBag.CateList;
    var cateListShowHome = (List<ProductCategoryDto>)ViewBag.CateListShowHome;
    var objList = (Dictionary<int, object>)ViewBag.ObjectList;
}
@if (cateListShowHome.Any())
{
    var count = 0;
    foreach (var cateItem in cateListShowHome)
    {
        var childMenuList = cateListAll.Where(x => x.ParentId == cateItem.Id && x.ShowHome).ToList();
        count++;
        var productList = (List<ProductRateByCateTopListPagingDto>)objList[count];
    <div class="homebycatebottom">
        <div class="pcList-header clearfix">
            <div class="pc-h-left fl">
                <a href="@Url.Action("Index", "CategoryL1", new { categoryName = StringUtil.RemoveSpecialCharactersVn(cateItem.Name), categoryId = cateItem.Id })" title="xem thêm @cateItem.Name">@cateItem.Name</a>
            </div>
            <div class="pc-h-right fr">
                @if (childMenuList.Any())
                {
                    <ul class="ul">
                        @foreach (var item in childMenuList)
                        {
                            <li>
                                <a href="@Url.Action("Index", "Category", new { categoryName = StringUtil.RemoveSpecialCharactersVn(item.Name), categoryId = item.Id })" rel="nofollow">@item.Name</a>
                            </li>
                        }
                        @* <a href="@Url.Action("Index", "CategoryL1", new { categoryName = StringUtil.RemoveSpecialCharactersVn(cateItem.Name), categoryId = cateItem.Id })" class="lnktitleSubList" title="xem thêm @cateItem.Name">
                                <i class="provi-icon-all"></i>
                                Xem thêm
                            </a>*@
                    </ul>
                }
            </div>
        </div>
        @{
                if (productList.Any())
                {
            <div class="CoListProduct homebycatebottom-list">
                <ul class="listp ul clearfix">
                    @foreach (var item in productList)
                    {
                        var pDetailLink = Url.Action("Index", "ProductDetail", new { productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name) });
                        <li>
                            <div class="pItem">
                                <a href="@pDetailLink" class="pItem-lnkImg">
                                    @if (item.PromotionPrice > 0)
                                    {
                                        <span class="pItem-per">-@item.DiscountPercentage.ToString("#.#")<i>%</i></span>
                                    }
                                    <img src="@item.ImagePath.ImagePathThumb(135, 135)" width="135" height="135" alt="@item.Name" class="lzLoading">
                                </a>
                                <div class="pItem-info">
                                    <div style="line-height: 13px; margin-top: 5px;">
                                        @{
                                    string StarPercent = "0";
                                    if (item.AverageRate > 0)
                                    {
                                        StarPercent = (Convert.ToDouble(item.AverageRate) * 100 / 5).ToString("#.#").Replace(',', '.');
                                    }
                                        }
                                        <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                                    </div>
                                    <h6>
                                        <a href="@pDetailLink">@item.Name</a>
                                    </h6>
                                    @if (item.PromotionPrice > 0)
                                    {
                                        <p class="pItem-PriceOld">
                                            @item.Price.ToString("##,###,###") đ
                                        </p>
                                        <p class="pItem-PriceNew">
                                            @item.PromotionPrice.ToString("##,###,###") <strong>đ</strong>
                                        </p>
                                    }
                                    else
                                    {
                                        <p class="pItem-PriceNew">
                                            @item.Price.ToString("##,###,###") <strong>đ</strong>
                                        </p>
                                    }

                                </div>
                            </div>
                        </li>
                    }
                </ul>
                <!--Provider by cate-->
                @*@Html.Action("ProviderByCate", "Home", new { Category = cateItem.Id, CateName = cateItem.Name })*@
            </div>
                }
        }
    </div>
    }
}